package com.example.laboratory.root_ui.UserInfoList;

import android.content.Intent;
import android.os.Bundle;
import com.example.laboratory.bean.UserList;
import com.example.laboratory.common.Const;
import com.example.laboratory.inter.OnUserInfoItemClickListener;
import com.example.laboratory.manager.UserInfoManager;
import com.example.laboratory.root_ui.adapter.UserInfoListAdapter;
import com.example.laboratory.ui.adapter.BaseListAdapter;
import com.example.laboratory.ui.base.BaseAbListActivity;
import com.example.laboratory.ui.base.BaseActivity;
import com.example.laboratory.ui.user.UserInfoActivity;

import java.util.List;

public class UserInfoListActivity extends BaseAbListActivity<UserInfoListPresenter, UserList.UserListBean> implements UserInfoListContact.IUserInfoListView , OnUserInfoItemClickListener {

    @Override
    protected void loadDatas() {
        mPresenter.getUserList(UserInfoManager.getUserInfo().getDepartId(),"1");
    }

    @Override
    protected BaseListAdapter<UserList.UserListBean> getListAdapter() {
        return new UserInfoListAdapter(this);
    }

    @Override
    protected UserInfoListPresenter createPresenter() {
        return new UserInfoListPresenter();
    }

    @Override
    public void setData(List<UserList.UserListBean> data) {
        mListData.clear();
        mListData.addAll(data);
    }

    @Override
    protected boolean initToolbar() {
        mToolbar.setTitle("学院安全员信息列表");
        return true;
    }

    @Override
    public void onItemClick(int position, UserList.UserListBean bean) {
        Intent intent = new Intent(this, UserInfoActivity.class);
        Bundle bundle = new Bundle();
        bundle.putSerializable(Const.BUNDLE_KEY.OBJ, bean);
        bundle.putString("cate","1");
        intent.putExtras(bundle);
        startActivity(intent);
    }
}
